import * as VueRouer from 'vue-router'
import Layout from '@/layout/index.vue'

const routes = [
  {
    path: '/',
    name: 'layout',
    component: Layout,
    redirect: 'home',
    children: [
      {
        path: 'home',
        name: 'home',
        component: () => import('@/views/home/index.vue')
      },
      {
        path: 'user',
        name: 'user',
        component: () => import('@/views/user/index.vue'),
        // redirect: 'user-home',
        children: [
          {
            path: '',
            name: 'user-home',
            component: () => import('@/views/user/views/UserHomeView.vue')
          },
          {
            path: 'article-list/:type',
            name: 'article-list',
            component: () => import('@/views/user/views/ArticleListView.vue'),
            props: true
          },
          {
            path: 'work-data',
            name: 'work-data',
            component: () => import('@/views/user/views/WorkDataView.vue'),
          },
          {
            path: 'favorite',
            name: 'favorite',
            component: () => import('@/views/user/views/FavoriteView.vue'),
          }
        ]
      },
      {
        path: 'user/editor',
        name: 'user-editor',
        component: () => import('@/views/user/views/UserEditorView.vue'),
      },
      {
        path: 'article/details/:id',
        name: 'article-details',
        component: () => import('@/views/article-details/index.vue'),
        props: true
      },
      {
        path: 'article/editor/:id',
        name: 'article-editor',
        component: () => import('@/views/article-editor/index.vue'),
        props: true
      },
      {
        path: '/404',
        name: '404-not-found',
        component: () => import('@/views/error/404NotFound.vue')
      },
      {
        path: '/chat',
        name: 'chat',
        component: () => import('@/views/chat/index.vue')
      },
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/:pathMatch(.*)*',
    redirect: '/404'
  }
]

const router = VueRouer.createRouter({
  mode: "history",
  history: VueRouer.createWebHashHistory(),
  routes
})


export default router